﻿using System;
using System.Collections.Generic;
using System.IO;
using CSJ2K.Util.IO;

namespace CSJ2K.Jpc.Segments
{
    /// <summary>End of codestream (EOC)</summary>
    /// <comment>
    /// Function: Indicates the end of the codestream. 
    ///      NOTE 1 – This marker shares the same code as the EOI marker in ITU-T Rec. T.81 
    ///          | ISO/IEC 10918-1. 
    /// Usage: Shall be the last marker in a codestream. There shall be one EOC per codestream. 
    ///      NOTE 2 – In the case a file has been corrupted, it is possible that a decoder 
    ///          could extract much useful compressed image data without encountering an EOC 
    ///          marker. 
    /// Length: Fixed.
    /// </comment>
    public class EOC : Segment
    {
        public EOC(Stream source)
            : this(source, (Markers)StreamUtil.ReadBUInt16(source)) { }
        public EOC(Stream source, Markers marker)
            : base(source, marker, false)
        {
            if (marker != Markers.EOC) throw (new ApplicationException("Attempting to create segment of the wrong type."));

        }
    }
}
